#ifndef GENAGENT_H
#define GENAGENT_H

#include <QObject>
#include <QList>
#include "Protocol.h"

class GenAgent: public QObject
{
	Q_OBJECT

	public:
		GenAgent(const TGenConfig& genConfig);
		~GenAgent();

	private:
		QTcpSocket *m_socket; // use to send and recv data
		TGenConfig m_genConfig;
		QList<TTranData> oldTranDataList;
		TTranData tranData;

	signals:
		void connectCompleted(int status);
		void commandCompleted(std::string genIP, int status);
		void dataArrived(std::string genIP, TSumInfo sumInfo);

	private slots:
		void readReadyHandle(); // recv reply from generator
		void initAgent();

	public slots:
		void ConnectGenerator(); // make sure the generator can work
		void SendCommand(int type); // send command like start, stop...
		void SendProfile(const TProfile& profile); // send generator profile
};

#endif
